package com.example.controller.aboutUser;

import com.example.vo.request.CreatePermissionForm;
import com.example.vo.request.EditPermissionDesForm;
import com.example.permission.PermissionCheck;
import com.example.service.aboutUser.PermissionService;
import com.example.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/permission")
public class PermissionController {

    @Resource
    private PermissionService permissionService;

    @GetMapping("/allPermissions")
    public Result getAllPermissions() {
        return permissionService.getAllPermissions();
    }

    @PostMapping ("/updatePermissionDescription")
    @PermissionCheck(permissionPath = "/systemManagement/permissionManagement/operatePermission")
    public Result updatePermissionDescription(@RequestBody EditPermissionDesForm editPermissionDesForm) {
        return permissionService.updatePermissionDescription(editPermissionDesForm);
    }

    @PostMapping("/createPermission")
    public Result createPermission(@RequestBody CreatePermissionForm createPermissionForm) {
        return permissionService.createPermission(createPermissionForm);
    }
}
